<extend file='resource/admin/base'/>
<block name="content">
    <ul class="nav nav-tabs" role="tablist">
        <li ><a href="{{u(index)}}" >文章管理</a></li>
        <li class="active"><a href="{{u(post)}}" >{{$oldData['art_id']?'文章编辑':'文章添加'}}</a></li>
    
    </ul>
    <form action="" method="post" role="form" class="form-horizontal" >
        <div class="panel panel-default">
            <!-- Default panel contents -->
            <div class="panel-heading">
                <h3 class="panel-title">文章管理</h3>
            </div>
            <div class="panel-body">

                <div class="form-group">
                    <label for="" class="col-sm-2 control-label">文章标题</label>
                    <div class="col-sm-10">
                        <input type="text" required name="art_title" value="{{$oldData['art_title']}}" class="form-control" >
                    </div>
                </div>
                <div class="form-group">
                    <label for="" class="col-sm-2 control-label">点击次数</label>
                    <div class="col-sm-10">
                        <input type="text" required name="art_click" value="{{$oldData['art_click']}}" class="form-control" >
                    </div>
                </div>
                <div class="form-group">
                    <label for="" class="col-sm-2 control-label">文章作者</label>
                    <div class="col-sm-10">
                        <input type="text" required name="art_author" value="{{$oldData['art_author']}}" class="form-control" >
                    </div>
                </div>
                <div class="form-group">
                    <label for="" class="col-sm-2 control-label">文章排序</label>
                    <div class="col-sm-10">
                        <input type="text" required name="art_sort" value="{{$oldData['art_sort']}}" class="form-control" >
                    </div>
                </div>
                <div class="form-group">
                    <label for="" class="col-sm-2 control-label">文章链接</label>
                    <div class="col-sm-10">
                        <input type="text" required name="art_linkurl" value="{{$oldData['art_linkurl']}}" class="form-control" >
                    </div>
                </div>
                <div class="form-group">
                    <label for="" class="col-sm-2 control-label">文章来源</label>
                    <div class="col-sm-10">
                        <input type="text" required name="art_source" value="{{$oldData['art_source']}}" class="form-control" >
                    </div>
                </div>
                <div class="form-group">
                    <label for="" class="col-sm-2 control-label">文章关键词</label>
                    <div class="col-sm-10">
                        <input type="text" required name="art_keyword" value="{{$oldData['art_keyword']}}" class="form-control" >
                        <span class="help-block">微信关键字</span>
                    </div>
                </div>
                <div class="form-group">
                    <label for="" class="col-sm-2 control-label">所属栏目</label>
                    <div class="col-sm-10">
                        <select name="cate_id" id="inputID" class="form-control">
                            <option value="0"> -- 请选择 -- </option>
                            <foreach from="$cateData" value="$d" >
                                <option <if value="$oldData['cate_id']==$d['cate_id']">selected</if>  value="{{$d['cate_id']}}"> -- {{$d['cate_name']}} -- </option>
                            </foreach>
                        </select>
                    </div>
                </div>
                <div class="form-group">
                    <label for="" class="col-sm-2 control-label">属性</label>
                    <div class="col-sm-10">
                        <div class="checkbox">
                            <label>
                                <input type="checkbox" value="1"  <if value="$oldData['art_ishot']=='1'">checked</if> name="art_ishot">热门
                            </label>
                            <label>
                                <input type="checkbox" value="1" <if value="$oldData['art_iscommed']=='1'">checked</if> name="art_iscommed">推荐
                            </label>
                        </div>
                    </div>
                </div>
                <!--        图片上传-->
                <div class="form-group">
                    <label for="" class="col-sm-2 control-label" >文章缩略图</label>
                    <div class="col-sm-10">
                        <div class="input-group">
                            <input type="text" class="form-control" name="art_thumb" readonly="" value="{{$oldData['art_thumb']}}">
                            <div class="input-group-btn">
                                <button onclick="upImage(this)" class="btn btn-default" type="button">选择图片</button>
                            </div>
                        </div>
                        <div class="input-group" style="margin-top:5px;">
                            <img src="{{pic($oldData['art_thumb'],'resource/images/nopic.jpg')}}" class="img-responsive img-thumbnail" width="150">
                            <em class="close" style="position:absolute; top: 0px; right: -14px;" title="删除这张图片" onclick="removeImg(this)">×</em>
                        </div>
                    </div>
                </div>
                


                <!--        图片上传-->
                    <div class="form-group">
                        <label for="" class="col-sm-2 control-label">文章描述</label>
                        <div class="col-sm-10">
                            <textarea class="form-control" required name="art_description">{{$oldData['art_description']}}</textarea>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="" class="col-sm-2 control-label">文章内容</label>
                        <div class="col-sm-10">
                            <textarea id="container" name="art_content" required style="height:300px;width:100%;">{{$oldData['art_content']}}</textarea>
                        </div>
                    </div>
                    <button type="submit" class="btn btn-primary">Submit</button>
            </div>
         </div>
         
    </form>
    <script>
        //上传图片
        function upImage(obj) {
            require(['util'], function (util) {
                options = {
                    multiple: false,//是否允许多图上传
                    //data是向后台服务器提交的POST数据
                    data:{name:'后盾人',year:2099},
                };
                util.image(function (images) {          //上传成功的图片，数组类型

                    $("[name='art_thumb']").val(images[0]);
                    $(".img-thumbnail").attr('src', images[0]);
                }, options)
            });
        }

        //移除图片
        function removeImg(obj) {
            $(obj).prev('img').attr('src', 'resource/images/nopic.jpg');
            $(obj).parent().prev().find('input').val('');
        }
    </script>
    <script>
        util.ueditor('container', {hash:2,data:'hd'}, function (editor) {
            //这是回调函数 editor是百度编辑器实例
        });
    </script>
</block>